package com.ruoyi.haircut.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.haircut.vo.CategoryDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.haircut.mapper.CategoryMapper;
import com.ruoyi.haircut.domain.Category;
import com.ruoyi.haircut.service.ICategoryService;

/**
 * 物品分类Service业务层处理
 *
 * @author Ms
 * @date 2023-05-11
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper,Category> implements ICategoryService
{
    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 查询物品分类
     *
     * @param id 物品分类主键
     * @return 物品分类
     */
    @Override
    public Category selectCategoryById(Long id)
    {
        return categoryMapper.selectCategoryById(id);
    }

    /**
     * 查询物品分类列表
     *
     * @param category 物品分类
     * @return 物品分类
     */
    @Override
    public List<Category> selectCategoryList(Category category)
    {
        return categoryMapper.selectCategoryList(category);
    }

    /**
     * 新增物品分类
     *
     * @param category 物品分类
     * @return 结果
     */
    @Override
    public int insertCategory(Category category)
    {
        category.setCreateTime(DateUtils.getNowDate());
        return categoryMapper.insertCategory(category);
    }

    /**
     * 修改物品分类
     *
     * @param category 物品分类
     * @return 结果
     */
    @Override
    public int updateCategory(Category category)
    {
        category.setUpdateTime(DateUtils.getNowDate());
        return categoryMapper.updateCategory(category);
    }

    /**
     * 批量删除物品分类
     *
     * @param ids 需要删除的物品分类主键
     * @return 结果
     */
    @Override
    public int deleteCategoryByIds(Long[] ids)
    {
        return categoryMapper.deleteCategoryByIds(ids);
    }

    /**
     * 删除物品分类信息
     *
     * @param id 物品分类主键
     * @return 结果
     */
    @Override
    public int deleteCategoryById(Long id)
    {
        return categoryMapper.deleteCategoryById(id);
    }

    @Override
    public List<CategoryDto> getCategoryIds() {
      return   categoryMapper.getCategoryIds();

    }


}
